|
![](/i/fill.gif) |
I wrote:
> > div(7, 3) = 2
> > div(-7, 3) = -3
> > div(7, -3) = -2
> > div(-7, -3) = 3
Thorsten Froehlich wrote:
> How can the result possibly be +-3 for any of these? No matter how you
> round, this makes only sense if you apply *different* rounding rules
> depending on the signs. And doing so is nonsensical.
No, the formulas I'm using are very simple and consistent:
div(a, b) = floor(a / b)
mod(a, b) = a - div(a, b)
Where floor always rounds down to the nearest integer.
Instead of floor, POV-Ray is using trunc (which POV-Ray calls int, but
shouldn't), and trunc rounds up if a number's less than zero, and down if a
number's greater than zero. So it's POV-Ray's current behavior that uses
different rounding rules, and in your own words, is nonsensical.
Anders
Post a reply to this message
|
![](/i/fill.gif) |